package com.xbongbong.saas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @description:
 * @Author: hongxiao
 * @date: 2019-01-13 09:38
 */
@Getter
public enum SmsTemplateStatusEnum {
    /**
     * 短信模板状态
     */
    APPLY_ING(0,"enum.smsTemplateStatus.name.apply_ing"),


    APPROVAL_ING(1,"enum.smsTemplateStatus.name.approval_ing"),


    APPROVAL_SUCCESS(2,"enum.smsTemplateStatus.name.approval_success"),


    APPROVAL_FAILURE(3,"enum.smsTemplateStatus.name.approval_failure"),


    UNKNOWN(404,"enum.smsTemplateStatus.name.unknown"),
    ;
    /**
     * 短信状态
     */
    private Integer code;
    /**
     * 短信状态名称
     */
    private String name;

    SmsTemplateStatusEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static SmsTemplateStatusEnum getByCode(Integer code) {
        for(SmsTemplateStatusEnum cacheCode : values()) {
            if (code.equals(cacheCode.getCode())) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
